import QtQuick 2.7
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
import "widget"
import "labels"
import "work/clock"

IndexPage {
    id:window
    StackView{
        id:stackView
        anchors.fill:parent
        onDepthChanged: {
            window.changeIsIndex(stackView.empty?true:false)
        }
        ColumnLayout{
            width:parent.width
            visible:stackView.empty?true:false
            spacing: 0
            Rectangle {
                Layout.fillWidth: true
                Layout.preferredHeight: 50
                color: "#2A9CFF"
                TitleLabel {
                    color: "#ffffff"
                    text: qsTr("工作")
                    anchors.fill: parent
                }
            }
            Image{
                source:"qrc:/img/work-banner.png"
                sourceSize: Qt.size(window.width,window.width*0.64)
                Layout.fillWidth: true
                Layout.preferredHeight: window.width*0.64
            }
            RowLayout{
                spacing:50
                Layout.fillWidth: true
                Layout.preferredHeight: 65
                Layout.topMargin: 30
                Layout.leftMargin: 18
                Layout.bottomMargin: 50

                Repeater{
                    model:[
                        {"text":"出勤天数","source":"qrc:/img/work-01.png","to":"qrc:/work/clock/Stat.qml"},
                        {"text":"通讯录","source":"qrc:/img/work-02.png","to":"qrc:/work/clock/Stat.qml"},
                        {"text":"制度查询","source":"qrc:/img/work-03.png","to":"qrc:/work/clock/Stat.qml"},
                        {"text":"消息","source":"qrc:/img/work-04.png","to":"qrc:/work/clock/Stat.qml"}
                    ]
                    WorkClickImg{
                        Layout.preferredWidth: 45
                        Layout.preferredHeight: 65
                        img_source:modelData.source
                        textlabel: modelData.text
                        onClicked:{
                            stackView.push(modelData.to)
                        }
                    }
                }
            }
            Rectangle{
                Layout.fillWidth: true
                Layout.preferredHeight: 1
                color:"#f7f7f7"
            }
            TitleLabel{
                Layout.fillWidth: true
                Layout.preferredHeight: 50
                text:"考勤管理"
                horizontalAlignment: Text.AlignLeft
                leftPadding:20
                font{
                    pixelSize: 15
                }
            }
            RowLayout{
                spacing:100
                Layout.fillWidth: true
                Layout.preferredHeight: 65
                Layout.leftMargin: 18

                Repeater{
                    model:[
                        {"text":"签到","source":"qrc:/img/work-05.png","to":"qrc:/work/clock/Clock.qml"},
                        {"text":"请假","source":"qrc:/img/work-06.png","to":"qrc:/work/clock/Stat.qml"},
                        {"text":"销假","source":"qrc:/img/work-07.png","to":"qrc:/work/clock/Stat.qml"},
                    ]
                    WorkClickImg{
                        Layout.preferredWidth: 45
                        Layout.preferredHeight: 65
                        img_source:modelData.source
                        textlabel: modelData.text
                        onClicked:{
                            stackView.push(modelData.to)
                        }
                    }
                }
            }
            Rectangle{
                Layout.fillWidth: true
                Layout.preferredHeight: 20
                color:"#f7f7f7"
            }
        }
    }

}
